#! /usr/bin/bash

AARCH64_LINUX_MUSL_GCC=$AARCH64_LINUX_MUSL_GCC_PATH/bin/aarch64-linux-musl-gcc

if [ ! -x "$AARCH64_LINUX_MUSL_GCC" ]; then
    echo 'AARCH64_LINUX_MUSL_GCC_PATH/bin/aarch64-linux-musl-gcc not found or executable.'
    exit
fi

cargo build \
    --config 'build.target = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-musl"]' \
    --config "target.aarch64-unknown-linux-musl.linker = \"$AARCH64_LINUX_MUSL_GCC\"" \
    --release
cp ./target/x86_64-unknown-linux-gnu/release/httg-hw-ws7002 "$HOME/opt/"
